$(function() {
	$('#vue_vm_list div').hide();
	
	findBySubjectRoomId(getLoginedUser().subjectRoomId);
});

var cgSendOrder = {
	cgSendOrderId: '',
	caregiverId: '',
	caregiverName: '',
	elderId: '',
	elderName: '',
	nursingCostId: '',
	nursingCostName: '',
	nursingCostPrice: '',
	caregiverSendOrdersStandardId: '',
	orderStandardName: '',
	orderStandardSalary: '',
	createTime: '',
	updateTime: '',
	createId: getLoginedUser()? getLoginedUser().staffId: '',
	updateId: getLoginedUser()? getLoginedUser().staffId: '',
	status: '',
};

function save() {
	view.data.nursingCostPrice = (view.data.nursingCostPrice==''? 0: parseFloat(view.data.nursingCostPrice));
	view.data.orderStandardSalary = (view.data.orderStandardSalary==''? 0: parseFloat(view.data.orderStandardSalary));
	view.data.status = (view.data.status==''? 0: parseInt(view.data.status));

	save_basic(path+'/cgSendOrder/save', {cgSendOrder:view.data}, function() {
		alert('保存成功');
		findAll();
	});
}

function findBySubjectRoomId(subjectRoomId) {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();

	find_basic_by_json(path+'/cgSendOrder/findBySubjectRoomId', {subjectRoomId: subjectRoomId}, function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			},
			methods: {
				finish:function(cgSendOrderId, calSalay) {
					save_basic_by_json(path+'/cgSendOrder/finish', {id:cgSendOrderId, calSalay:calSalay}, function() {
						$('#' + cgSendOrderId + '_status').text('状态：已结束');
						$('#' + cgSendOrderId + '_finish_0').hide();
						$('#' + cgSendOrderId + '_finish_1').hide();
						alert('结束成功');
					});
				}
			}
		});
		
		$('#vue_vm_list div').show();
	});
}

function deleteBatch() {
	deleteBatch_basic(path+'/cgSendOrder/deleteBatch');
}
